package com.hibernate.learn4.model;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

@Entity
@Table(name = "Students")
public class Userr {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private int id;

    @Column(name = "name")
    private String UserrName;

    @ManyToMany(cascade = CascadeType.ALL)
    @JoinTable(name = "student_college",
            joinColumns = @JoinColumn(name = "student_id"),
            inverseJoinColumns = @JoinColumn(name = "college_id"))
    private List<College> colleges = new ArrayList<>();

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getUserrName() {
        return UserrName;
    }

    public void setUserrName(String userrName) {
        UserrName = userrName;
    }

    public List<College> getColleges() {
        return colleges;
    }

    public void setColleges(List<College> colleges) {
        this.colleges = colleges;
    }

    public void setCollege(College college) {
        this.colleges.add(college);
    }
}
